//
//  WMUtil.h
//  RCIM
//
//  Created by 郑文明 on 16/1/13.
//  Copyright © 2016年 郑文明. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MBProgressHUD.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <Foundation/NSObject.h>
@interface WMUtil : NSObject
+ (NSDictionary *)getDictionaryFromPlistWithPathString:(NSString *)pathString;
+ (NSArray *)getArrayFromPlistWithPathString:(NSString *)pathString;
+ (void)setDataFromPlistWithPathString:(NSString *)pathString dictionary:(NSDictionary *)dictionary;
+ (void)setDataFromPlistWithPathString:(NSString *)pathString array:(NSArray *)array;

+ (NSMutableAttributedString *)attributedStringWithText:(NSString *)text withRangText:(NSString *)rangeText withColor:(UIColor *)color withFont:(UIFont *)font;
+ (NSAttributedString *)attributedStringWithText:(NSString *)text withColor:(UIColor *)color withFont:(UIFont *)font lineSpacing:(CGFloat)lineSpacing ziJianJu:(CGFloat)ziJianJu;
+ (CGSize)sizeWithAttributedtext:(NSAttributedString *)attributedtext maxSize:(CGSize)maxSize;
+ (CGSize)sizeWithtext:(NSString *)text maxSize:(CGSize)maxSize withFont:(UIFont *)font lineSpacing:(CGFloat)lineSpacing ziJianJu:(CGFloat)ziJianJu;
+ (NSDictionary*)dictionaryFromBundleWithName:(NSString*)fileName withType:(NSString*)typeName;
//字符串MD5转换
+ (NSString *)md5HexDigest:(NSString*)input;
+(NSString *)fileMd5sum:(NSString * )filename; //md5转换
//ios8以上 拨打电话
+ (void)callPhoneActionWithPhoneNum:(NSString *)phoneNum WithViewController:(UIViewController *)weakSelf;
//时间格式
+ (NSDate *)getNowTime;
+ (NSString *)getyyyymmdd;
+(NSString *)getyyyymmddHHmmss;
+(NSString *)getyyyymmddHHmm;
+ (NSString *)get1970timeString;
+ (NSString *)getTimeString:(NSDate *)date;
+ (NSString *)gethhmmss;
+ (BOOL)compareDate:(NSDate*)stary withDate:(NSDate*)end;

+ (BOOL)checkTheDate:(NSString *)string;






+ (void)showTipsWithHUD:(NSString *)labelText;
+ (void)showTipsWithHUD:(NSString *)labelText inView:(UIView *)inView;
+ (void)showTipsWithView:(UIView *)uiview labelText:(NSString *)labelText showTime:(CGFloat)time;
+ (void) showHudMessage:(NSString*) msg hideAfterDelay:(NSInteger) sec uiview:(UIView *)uiview;

//+ (NetworkStatus)getCurrentNetworkStatus;
+ (void)showNotReachabileTips;
//算距离
//+ (double)getDistanceWithLongitude:(NSString *)longitude latitude:(NSString *)latitude;

+ (NSDate *)dateFromString:(NSString *)dateString usingFormat:(NSString*)format;
+ (NSDate *)dateFromString:(NSString *)dateString;
+ (NSString *)stringFromDate:(NSDate *)date;
+ (NSString *)stringFromDate:(NSDate *)date usingFormat:(NSString*)format;
+ (NSString *)timeStringWithDataString:(NSString *)dateString formatterString:(NSString *)formatterString;
//获取后台服务器主机名
//+(NSString*)readFromUmengOlineHostname;

//loadingView方法集
+(void)addLoadingViewInView:(UIView*)viewToLoadData usingUIActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)aStyle;
+(void)removeLoadingViewInView:(UIView*)viewToLoadData;
+(void)addLoadingViewInView:(UIView*)viewToLoadData usingUIActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)aStyle usingColor:(UIColor*)color;
+(void)removeLoadingViewAndLabelInView:(UIView*)viewToLoadData;
+(void)addLoadingViewAndLabelInView:(UIView*)viewToLoadData usingOrignalYPosition:(CGFloat)yPosition;
+(void)showProgessInView:(UIView *)view withExtBlock:(void (^)())exBlock withComBlock:(void (^)())comBlock;
+ (UIImage *)image:(UIImage *)image rotation:(UIImageOrientation)orientation; //图片旋转

//将图片保存到应用程序沙盒中去,imageNameString的格式为 @"upLoad.png"
+ (void)saveImagetoLocal:(UIImage*)image imageName:(NSString *)imageNameString;
+ (NSString *)getDeviceOSType;


//判断字符串长度
+ (int)convertToInt:(NSString*)strtemp;
//end

+(NSMutableArray *)decorateString:(NSString *)string;
//邮箱 正则表达式部分
+ (BOOL) validateEmail:(NSString *)email;
//手机号码验证
+ (BOOL) validateMobile:(NSString *)mobile;
//用户名
+ (BOOL) validateUserName:(NSString *)name;
//密码
+ (BOOL) validatePassword:(NSString *)passWord;
//昵称
+ (BOOL) validateNickname:(NSString *)nickname;
//身份证号
+ (BOOL) validateIdentityCard:(NSString *)identityCard;
//银行卡
+ (BOOL) validateBankCardNumber:(NSString *)bankCardNumber;
//银行卡后四位
+ (BOOL) validateBankCardLastNumber: (NSString *)bankCardNumber;
//CVN
+ (BOOL) validateCVNCode: (NSString *)cvnCode;
//month
+ (BOOL) validateMonth: (NSString *)month;
//year
+ (BOOL) validateYear: (NSString *)year;
//verifyCode
+ (BOOL) validateVerifyCode: (NSString *)verifyCode;
//判断是否为数字
+ (BOOL) isPureInt:(NSString*)string;

//字符串去掉空格
+(NSString *)stringByReplacing:(NSString *)str;





//压缩图片质量
+(UIImage *)reduceImage:(UIImage *)image percent:(float)percent;
//压缩图片尺寸
+ (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize;
+ (UIColor *) colorWithHexString: (NSString *)color;
+ (NSString *)documentsDirectoryPath;
/**
 *  返回字符串所占用的尺寸
 *
 *  @param fontSize    字体
 *  @param stringSize 最大尺寸
 */
+ (CGSize)getWidthByString:(NSString*)string withFont:(UIFont*)stringFont withStringSize:(CGSize)stringSize;
/**
 *  正则表达式验证数字
 */
+ (BOOL)checkNum:(NSString *)str;

// View转化为图片
+ (UIImage *)getImageFromView:(UIView *)view;
// imageView转化为图片
+ (UIImage *)getImageFromImageView:(UIImageView *)imageView;

+ (BOOL)isLocationOpen;//判断是否打开定位
+ (NSInteger)getCellMaxNum:(CGFloat)cellHeight maxHeight:(CGFloat)height;//得到tableview最大页数
//匹配数字和英文字母
+ (BOOL) isNumberOrEnglish:(NSString *)string;
//匹配数字
+ (BOOL) isKimiNumber:(NSString *)number;
//是否存在字段
+ (BOOL)rangeString:(NSString *)string searchString:(NSString *)searchString;

//时间戳转字符串
+ (NSString *)createTime:(NSString *)time   setDateFormatString:(NSString *)setDateFormat;
// 获取当前系统时间戳
+(long)getTimeSp;


//将当前时间字符串转为UTCDate
+ (NSDate *)UTCDateFromLocalString:(NSString *)localString;


+ (NSDateComponents *)pleaseInsertStarTimeo:(NSDate *)time1 andInsertEndTime:(NSDate *)time;

// 算出字符串长度
+ (CGSize)strName:(NSString *)str  fontSize:(UIFont *)font  boundingRectWithSize:(CGSize)size;



// 随机数
+ (int)getRandomNumber:(int)from to:(int)to;

// 判断是否有空
+ (BOOL)isBlank:(NSString*)str;


@end
